home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / intoids.lha / Intoids 1.0 / Developer / GCC / os-include / inline / Intoids.h
C/C++ Source or Header  |  1997-02-12  |  15KB  |  450 lines

  1. #ifndef _INLINE_INTOIDS_H
  2. #define _INLINE_INTOIDS_H 1
  3.  
  4. /******************************************************************************
  5.  * $Header: Big:Programming/C/Intoids/Library/RCS/Intoids_inline.h,v 1.3 1997/02/12 17:09:53 AGMS Exp $
  6.  *
  7.  * GNU C inline function call glue for intoids.library users.
  8.  *
  9.  * Look in Intoids.c for documentation (autodocs generated from there), e-mail
  10.  * addresses and credits.  See Libraries/Intoids.h for datatypes.
  11.  *
  12.  * Intoids.library - An Amiga runtime shared code library for efficiently
  13.  * handling large and small integer values using pointer sized data fields.
  14.  *
  15.  * Modifications for storing smaller integers in 32 bit values and conversion
  16.  * to an Amiga library copyright © 1996 by Alexander G. M. Smith.
  17.  * Original long integer code copyright © 1988 Free Software Foundation.
  18.  *
  19.  * This library is free software; you can redistribute it and/or
  20.  * modify it under the terms of the GNU Library General Public
  21.  * License as published by the Free Software Foundation; either
  22.  * version 2 of the License, or (at your option) any later version.
  23.  *
  24.  * This library is distributed in the hope that it will be useful,
  25.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  27.  * Library General Public License for more details.
  28.  *
  29.  * You should have received a copy of the GNU Library General Public
  30.  * License along with this library; if not, write to the Free
  31.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32.  */
  33.  
  34. #ifndef _CDEFS_H_
  35. #include <sys/cdefs.h>    /* For __BEGIN_DECLS, so it works from C++ */
  36. #endif
  37. #ifndef _INLINE_STUBS_H_
  38. #include <inline/stubs.h> /* Defines an empty struct Library etc. */
  39. #endif
  40.  
  41. __BEGIN_DECLS
  42.  
  43. #ifndef BASE_EXT_DECL
  44. #define BASE_EXT_DECL
  45. #define BASE_EXT_DECL0 extern struct Library *IntoidsBase;
  46. #endif
  47. #ifndef BASE_PAR_DECL
  48. #define BASE_PAR_DECL
  49. #define BASE_PAR_DECL0 void
  50. #endif
  51. #ifndef BASE_NAME
  52. #define BASE_NAME IntoidsBase
  53. #endif
  54.  
  55. BASE_EXT_DECL0
  56.  
  57. /* Note that these functions are in alphabetical order,
  58.    for easier maintenance. */
  59.  
  60. extern __inline Intoid
  61. AbsoluteIntoid (BASE_PAR_DECL Intoid IntegerA, Intoid RecycleMe)
  62. {
  63.         BASE_EXT_DECL
  64.         register Intoid _res __asm("d0");
  65.         register struct Library *a6 __asm("a6") = BASE_NAME;
  66.         register Intoid d0 __asm("d0") = IntegerA;
  67.         register Intoid d1 __asm("d1") = RecycleMe;
  68.         __asm __volatile ("jsr a6@(-0x60)"
  69.         : "=r" (_res)
  70.         : "r" (a6), "r" (d0), "r" (d1)
  71.         : "d0", "d1", "a0", "a1", "memory");
  72.         return _res;
  73. }
  74.  
  75. extern __inline Intoid
  76. AddIntoids (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB, Intoid RecycleMe)
  77. {
  78.         BASE_EXT_DECL
  79.         register Intoid _res __asm("d0");
  80.         register struct Library *a6 __asm("a6") = BASE_NAME;
  81.         register Intoid d0 __asm("d0") = IntegerA;
  82.         register Intoid d1 __asm("d1") = IntegerB;
  83.         register Intoid a0 __asm("a0") = RecycleMe;
  84.         __asm __volatile ("jsr a6@(-0x66)"
  85.         : "=r" (_res)
  86.         : "r" (a6), "r" (d0), "r" (d1), "r" (a0)
  87.         : "d0", "d1", "a0", "a1", "memory");
  88.         return _res;
  89. }
  90.  
  91. extern __inline Intoid
  92. AsciiToIntoid (BASE_PAR_DECL STRPTR Buffer, char ** NextCharacterPntrPntr, UWORD Base, Intoid RecycleMe)
  93. {
  94.         BASE_EXT_DECL
  95.         register Intoid _res __asm("d0");
  96.         register struct Library *a6 __asm("a6") = BASE_NAME;
  97.         register STRPTR a0 __asm("a0") = Buffer;
  98.         register char ** a1 __asm("a1") = NextCharacterPntrPntr;
  99.         register UWORD d0 __asm("d0") = Base;
  100.         register Intoid d1 __asm("d1") = RecycleMe;
  101.         __asm __volatile ("jsr a6@(-0x4e)"
  102.         : "=r" (_res)
  103.         : "r" (a6), "r" (a0), "r" (a1), "r" (d0), "r" (d1)
  104.         : "d0", "d1", "a0", "a1", "memory");
  105.         return _res;
  106. }
  107.  
  108. extern __inline LONG
  109. CompareIntoidMagnitudes (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB)
  110. {
  111.         BASE_EXT_DECL
  112.         register LONG _res __asm("d0");
  113.         register struct Library *a6 __asm("a6") = BASE_NAME;
  114.         register Intoid d0 __asm("d0") = IntegerA;
  115.         register Intoid d1 __asm("d1") = IntegerB;
  116.         __asm __volatile ("jsr a6@(-0x78)"
  117.         : "=r" (_res)
  118.         : "r" (a6), "r" (d0), "r" (d1)
  119.         : "d0", "d1", "a0", "a1", "memory");
  120.         return _res;
  121. }
  122.  
  123. extern __inline LONG
  124. CompareIntoids (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB)
  125. {
  126.         BASE_EXT_DECL
  127.         register LONG _res __asm("d0");
  128.         register struct Library *a6 __asm("a6") = BASE_NAME;
  129.         register Intoid d0 __asm("d0") = IntegerA;
  130.         register Intoid d1 __asm("d1") = IntegerB;
  131.         __asm __volatile ("jsr a6@(-0x72)"
  132.         : "=r" (_res)
  133.         : "r" (a6), "r" (d0), "r" (d1)
  134.         : "d0", "d1", "a0", "a1", "memory");
  135.         return _res;
  136. }
  137.  
  138. extern __inline Intoid
  139. CopyIntoid (BASE_PAR_DECL Intoid IntegerA, Intoid RecycleMe)
  140. {
  141.         BASE_EXT_DECL
  142.         register Intoid _res __asm("d0");
  143.         register struct Library *a6 __asm("a6") = BASE_NAME;
  144.         register Intoid d0 __asm("d0") = IntegerA;
  145.         register Intoid d1 __asm("d1") = RecycleMe;
  146.         __asm __volatile ("jsr a6@(-0x54)"
  147.         : "=r" (_res)
  148.         : "r" (a6), "r" (d0), "r" (d1)
  149.         : "d0", "d1", "a0", "a1", "memory");
  150.         return _res;
  151. }
  152.  
  153. extern __inline Intoid
  154. DivideIntoids (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB, Intoid RecycleMe)
  155. {
  156.         BASE_EXT_DECL
  157.         register Intoid _res __asm("d0");
  158.         register struct Library *a6 __asm("a6") = BASE_NAME;
  159.         register Intoid d0 __asm("d0") = IntegerA;
  160.         register Intoid d1 __asm("d1") = IntegerB;
  161.         register Intoid a0 __asm("a0") = RecycleMe;
  162.         __asm __volatile ("jsr a6@(-0x84)"
  163.         : "=r" (_res)
  164.         : "r" (a6), "r" (d0), "r" (d1), "r" (a0)
  165.         : "d0", "d1", "a0", "a1", "memory");
  166.         return _res;
  167. }
  168.  
  169. extern __inline VOID
  170. FreeIntoid (BASE_PAR_DECL Intoid RecycleMe)
  171. {
  172.         BASE_EXT_DECL
  173.         register struct Library *a6 __asm("a6") = BASE_NAME;
  174.         register Intoid a0 __asm("a0") = RecycleMe;
  175.         __asm __volatile ("jsr a6@(-0x1e)"
  176.         : /* No Output */
  177.         : "r" (a6), "r" (a0)
  178.         : "d0", "d1", "a0", "a1", "memory");
  179. }
  180.  
  181. extern __inline STRPTR
  182. GetIntoidsMessage (BASE_PAR_DECL IntoidStringNumbers StringNumber)
  183. {
  184.         BASE_EXT_DECL
  185.         register STRPTR _res __asm("d0");
  186.         register struct Library *a6 __asm("a6") = BASE_NAME;
  187.         register IntoidStringNumbers d0 __asm("d0") = StringNumber;
  188.         __asm __volatile ("jsr a6@(-0x2a)"
  189.         : "=r" (_res)
  190.         : "r" (a6), "r" (d0)
  191.         : "d0", "d1", "a0", "a1", "memory");
  192.         return _res;
  193. }
  194.  
  195. extern __inline STRPTR
  196. GetLastIntoidErrorMessage (BASE_PAR_DECL0)
  197. {
  198.         BASE_EXT_DECL
  199.         register STRPTR _res __asm("d0");
  200.         register struct Library *a6 __asm("a6") = BASE_NAME;
  201.         __asm __volatile ("jsr a6@(-0x24)"
  202.         : "=r" (_res)
  203.         : "r" (a6)
  204.         : "d0", "d1", "a0", "a1", "memory");
  205.         return _res;
  206. }
  207.  
  208. extern __inline BOOL
  209. IntoidFitsInLong (BASE_PAR_DECL Intoid IntegerA)
  210. {
  211.         BASE_EXT_DECL
  212.         register BOOL _res __asm("d0");
  213.         register struct Library *a6 __asm("a6") = BASE_NAME;
  214.         register Intoid d0 __asm("d0") = IntegerA;
  215.         __asm __volatile ("jsr a6@(-0x36)"
  216.         : "=r" (_res)
  217.         : "r" (a6), "r" (d0)
  218.         : "d0", "d1", "a0", "a1", "memory");
  219.         return _res;
  220. }
  221.  
  222. extern __inline LONG
  223. IntoidToAscii (BASE_PAR_DECL Intoid IntegerA, STRPTR Buffer, LONG BufferLength, UWORD Base)
  224. {
  225.         BASE_EXT_DECL
  226.         register LONG _res __asm("d0");
  227.         register struct Library *a6 __asm("a6") = BASE_NAME;
  228.         register Intoid a0 __asm("a0") = IntegerA;
  229.         register STRPTR a1 __asm("a1") = Buffer;
  230.         register LONG d0 __asm("d0") = BufferLength;
  231.         register UWORD d1 __asm("d1") = Base;
  232.         __asm __volatile ("jsr a6@(-0x48)"
  233.         : "=r" (_res)
  234.         : "r" (a6), "r" (a0), "r" (a1), "r" (d0), "r" (d1)
  235.         : "d0", "d1", "a0", "a1", "memory");
  236.         return _res;
  237. }
  238.  
  239. extern __inline LONG
  240. IntoidToLong (BASE_PAR_DECL Intoid IntegerA)
  241. {
  242.         BASE_EXT_DECL
  243.         register LONG _res __asm("d0");
  244.         register struct Library *a6 __asm("a6") = BASE_NAME;
  245.         register Intoid d0 __asm("d0") = IntegerA;
  246.         __asm __volatile ("jsr a6@(-0x3c)"
  247.         : "=r" (_res)
  248.         : "r" (a6), "r" (d0)
  249.         : "d0", "d1", "a0", "a1", "memory");
  250.         return _res;
  251. }
  252.  
  253. extern __inline BOOL
  254. IntoidToPortableIntViaBuffer (BASE_PAR_DECL Intoid AnIntoid, ULONG * BytesWrittenPntr, APTR Buffer, ULONG BufferSize)
  255. {
  256.         BASE_EXT_DECL
  257.         register BOOL _res __asm("d0");
  258.         register struct Library *a6 __asm("a6") = BASE_NAME;
  259.         register Intoid d0 __asm("d0") = AnIntoid;
  260.         register ULONG * a0 __asm("a0") = BytesWrittenPntr;
  261.         register APTR a1 __asm("a1") = Buffer;
  262.         register ULONG d1 __asm("d1") = BufferSize;
  263.         __asm __volatile ("jsr a6@(-0xa8)"
  264.         : "=r" (_res)
  265.         : "r" (a6), "r" (d0), "r" (a0), "r" (a1), "r" (d1)
  266.         : "d0", "d1", "a0", "a1", "memory");
  267.         return _res;
  268. }
  269.  
  270. extern __inline BOOL
  271. IntoidToPortableIntViaCallBack (BASE_PAR_DECL Intoid AnIntoid, ULONG * BytesWrittenPntr, PortIntCallBackPntr CallBack, APTR UserPntr)
  272. {
  273.         BASE_EXT_DECL
  274.         register BOOL _res __asm("d0");
  275.         register struct Library *a6 __asm("a6") = BASE_NAME;
  276.         register Intoid d0 __asm("d0") = AnIntoid;
  277.         register ULONG * a0 __asm("a0") = BytesWrittenPntr;
  278.         register PortIntCallBackPntr d1 __asm("d1") = CallBack;
  279.         register APTR a1 __asm("a1") = UserPntr;
  280.         __asm __volatile ("jsr a6@(-0xa2)"
  281.         : "=r" (_res)
  282.         : "r" (a6), "r" (d0), "r" (a0), "r" (d1), "r" (a1)
  283.         : "d0", "d1", "a0", "a1", "memory");
  284.         return _res;
  285. }
  286.  
  287. extern __inline Intoid
  288. LongToIntoid (BASE_PAR_DECL LONG LongA, Intoid RecycleMe)
  289. {
  290.         BASE_EXT_DECL
  291.         register Intoid _res __asm("d0");
  292.         register struct Library *a6 __asm("a6") = BASE_NAME;
  293.         register LONG d0 __asm("d0") = LongA;
  294.         register Intoid a0 __asm("a0") = RecycleMe;
  295.         __asm __volatile ("jsr a6@(-0x42)"
  296.         : "=r" (_res)
  297.         : "r" (a6), "r" (d0), "r" (a0)
  298.         : "d0", "d1", "a0", "a1", "memory");
  299.         return _res;
  300. }
  301.  
  302. extern __inline Intoid
  303. MultiplyIntoids (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB, Intoid RecycleMe)
  304. {
  305.         BASE_EXT_DECL
  306.         register Intoid _res __asm("d0");
  307.         register struct Library *a6 __asm("a6") = BASE_NAME;
  308.         register Intoid d0 __asm("d0") = IntegerA;
  309.         register Intoid d1 __asm("d1") = IntegerB;
  310.         register Intoid a0 __asm("a0") = RecycleMe;
  311.         __asm __volatile ("jsr a6@(-0x7e)"
  312.         : "=r" (_res)
  313.         : "r" (a6), "r" (d0), "r" (d1), "r" (a0)
  314.         : "d0", "d1", "a0", "a1", "memory");
  315.         return _res;
  316. }
  317.  
  318. extern __inline Intoid
  319. NegateIntoid (BASE_PAR_DECL Intoid IntegerA, Intoid RecycleMe)
  320. {
  321.         BASE_EXT_DECL
  322.         register Intoid _res __asm("d0");
  323.         register struct Library *a6 __asm("a6") = BASE_NAME;
  324.         register Intoid d0 __asm("d0") = IntegerA;
  325.         register Intoid d1 __asm("d1") = RecycleMe;
  326.         __asm __volatile ("jsr a6@(-0x5a)"
  327.         : "=r" (_res)
  328.         : "r" (a6), "r" (d0), "r" (d1)
  329.         : "d0", "d1", "a0", "a1", "memory");
  330.         return _res;
  331. }
  332.  
  333. extern __inline ULONG
  334. PortableIntLengthViaBuffer (BASE_PAR_DECL APTR Buffer, ULONG BufferSize)
  335. {
  336.         BASE_EXT_DECL
  337.         register ULONG _res __asm("d0");
  338.         register struct Library *a6 __asm("a6") = BASE_NAME;
  339.         register APTR a0 __asm("a0") = Buffer;
  340.         register ULONG d1 __asm("d1") = BufferSize;
  341.         __asm __volatile ("jsr a6@(-0x90)"
  342.         : "=r" (_res)
  343.         : "r" (a6), "r" (a0), "r" (d1)
  344.         : "d0", "d1", "a0", "a1", "memory");
  345.         return _res;
  346. }
  347.  
  348. extern __inline ULONG
  349. PortableIntLengthViaCallBack (BASE_PAR_DECL PortIntCallBackPntr CallBack, APTR UserPntr)
  350. {
  351.         BASE_EXT_DECL
  352.         register ULONG _res __asm("d0");
  353.         register struct Library *a6 __asm("a6") = BASE_NAME;
  354.         register PortIntCallBackPntr d0 __asm("d0") = CallBack;
  355.         register APTR d1 __asm("d1") = UserPntr;
  356.         __asm __volatile ("jsr a6@(-0x8a)"
  357.         : "=r" (_res)
  358.         : "r" (a6), "r" (d0), "r" (d1)
  359.         : "d0", "d1", "a0", "a1", "memory");
  360.         return _res;
  361. }
  362.  
  363. extern __inline ULONG
  364. PortableIntSizeOfIntoid (BASE_PAR_DECL Intoid AnIntoid)
  365. {
  366.         BASE_EXT_DECL
  367.         register ULONG _res __asm("d0");
  368.         register struct Library *a6 __asm("a6") = BASE_NAME;
  369.         register Intoid a0 __asm("a0") = AnIntoid;
  370.         __asm __volatile ("jsr a6@(-0xae)"
  371.         : "=r" (_res)
  372.         : "r" (a6), "r" (a0)
  373.         : "d0", "d1", "a0", "a1", "memory");
  374.         return _res;
  375. }
  376.  
  377. extern __inline Intoid
  378. PortableIntToIntoidViaBuffer (BASE_PAR_DECL APTR Buffer, ULONG BufferSize, ULONG * AmountReadPntr, Intoid RecycleMe)
  379. {
  380.         BASE_EXT_DECL
  381.         register Intoid _res __asm("d0");
  382.         register struct Library *a6 __asm("a6") = BASE_NAME;
  383.         register APTR a0 __asm("a0") = Buffer;
  384.         register ULONG d0 __asm("d0") = BufferSize;
  385.         register ULONG * a1 __asm("a1") = AmountReadPntr;
  386.         register Intoid d1 __asm("d1") = RecycleMe;
  387.         __asm __volatile ("jsr a6@(-0x9c)"
  388.         : "=r" (_res)
  389.         : "r" (a6), "r" (a0), "r" (d0), "r" (a1), "r" (d1)
  390.         : "d0", "d1", "a0", "a1", "memory");
  391.         return _res;
  392. }
  393.  
  394. extern __inline Intoid
  395. PortableIntToIntoidViaCallBack (BASE_PAR_DECL PortIntCallBackPntr CallBack, APTR UserPntr, ULONG * AmountReadPntr, Intoid RecycleMe)
  396. {
  397.         BASE_EXT_DECL
  398.         register Intoid _res __asm("d0");
  399.         register struct Library *a6 __asm("a6") = BASE_NAME;
  400.         register PortIntCallBackPntr a0 __asm("a0") = CallBack;
  401.         register APTR d0 __asm("d0") = UserPntr;
  402.         register ULONG * a1 __asm("a1") = AmountReadPntr;
  403.         register Intoid d1 __asm("d1") = RecycleMe;
  404.         __asm __volatile ("jsr a6@(-0x96)"
  405.         : "=r" (_res)
  406.         : "r" (a6), "r" (a0), "r" (d0), "r" (a1), "r" (d1)
  407.         : "d0", "d1", "a0", "a1", "memory");
  408.         return _res;
  409. }
  410.  
  411. extern __inline LONG
  412. SignOfIntoid (BASE_PAR_DECL Intoid IntegerA)
  413. {
  414.         BASE_EXT_DECL
  415.         register LONG _res __asm("d0");
  416.         register struct Library *a6 __asm("a6") = BASE_NAME;
  417.         register Intoid d0 __asm("d0") = IntegerA;
  418.         __asm __volatile ("jsr a6@(-0x30)"
  419.         : "=r" (_res)
  420.         : "r" (a6), "r" (d0)
  421.         : "d0", "d1", "a0", "a1", "memory");
  422.         return _res;
  423. }
  424.  
  425. extern __inline Intoid
  426. SubtractIntoids (BASE_PAR_DECL Intoid IntegerA, Intoid IntegerB, Intoid RecycleMe)
  427. {
  428.         BASE_EXT_DECL
  429.         register Intoid _res __asm("d0");
  430.         register struct Library *a6 __asm("a6") = BASE_NAME;
  431.         register Intoid d0 __asm("d0") = IntegerA;
  432.         register Intoid d1 __asm("d1") = IntegerB;
  433.         register Intoid a0 __asm("a0") = RecycleMe;
  434.         __asm __volatile ("jsr a6@(-0x6c)"
  435.         : "=r" (_res)
  436.         : "r" (a6), "r" (d0), "r" (d1), "r" (a0)
  437.         : "d0", "d1", "a0", "a1", "memory");
  438.         return _res;
  439. }
  440.  
  441. #undef BASE_EXT_DECL
  442. #undef BASE_EXT_DECL0
  443. #undef BASE_PAR_DECL
  444. #undef BASE_PAR_DECL0
  445. #undef BASE_NAME
  446.  
  447. __END_DECLS
  448.  
  449. #endif /* _INLINE_INTOIDS_H */
  450.